<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>canvas</title>
    <style>
        *{
            margin:0;padding:0;
            overflow:hidden;
        }
        html,body{
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
    <!-- 画布 1. 添加 canvas 标签 -->
    <canvas></canvas>

    <script>
        //2. 获取 canvas 元素
        let canvas = document.querySelector('canvas');

        //3. 初始化    documentElement  html    document.body    document.head  document.title 获取与修改标题
        canvas.width = document.documentElement.clientWidth;
        canvas.height = document.documentElement.clientHeight;

        //4. 获取画笔对象  three.js 用来做三维效果
        let ctx = canvas.getContext('2d');

        //绑定事件
        canvas.ontouchstart = function(e){
            ctx.beginPath();
            //设置画笔的起点
            ctx.moveTo(e.targetTouches[0].pageX, e.targetTouches[0].pageY);
            e.preventDefault();
        }

        canvas.ontouchmove = function(e){
            ctx.lineTo(e.targetTouches[0].pageX, e.targetTouches[0].pageY);
            //描边
            ctx.stroke();
        }

        canvas.ontouchend = function(){

        }



    </script>
</body>
</html>